package cn.zysheep.controller;

import cn.zysheep.utils.QRBarCodeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @version v1.0
 * @Author: lyw
 * @Date: 2021/8/11
 */
@Controller
public class QRCodeController {

    @GetMapping({"/"})
    public String index() {
        return "qr";
    }
    @GetMapping("qrCode")
    public void getQRCode(String codeContent, HttpServletResponse response) {
        System.out.println("codeContent=" + codeContent);
        try {
            /**
             * 调用工具类生成二维码并输出到输出流中
             */
            QRBarCodeUtil.createCodeToOutputStream(codeContent, response.getOutputStream());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
